﻿#pragma once
#include "yzrutil.h"
namespace yzrilyzr_ast{
	EBCLASS(CharReader){
	public:
		const char *arr;
		u_index index=0;
		u_index col=0;
		u_index line=0;
		u_index length=0;
	public:
	CharReader(const char *chars){
		this->arr=chars;
		this->length=strlen(chars);
	}
	char get(){
		return arr[index];
	}
	void next(){
		index+=1;
	}
	bool has(){
		return index<length;
	}
	char get(u_index offset){
		return arr[index+offset];
	}
	/*yzrilyzr_lang::String toString()override{
		String sb=new String();
		sb.append(arr);
		sb.insert(index,"[POSITION->");
		return sb.toString();
	}*/
	void back(){
		index-=1;
	}
	bool isNot(const char *endOf){
		u_index len=strlen(endOf);
		for(u_index i=0;i<len;i++){
			if(endOf[i]==arr[index]) return false;
		}
		return true;
	}
	u_index available(){
		return length-index;
	}
	};
}